<!doctype html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>微联盟系统</title>
    <link rel="stylesheet" href="{:C('__STATIC__')}{$theme}/Static/{:C('css')}/login.css" />
    <link rel="stylesheet" href="{:C('__STATIC__')}{$theme}/Static/{:C('css')}/common.css" />
</head>
<body>
    <div class="banx-a">
        <form action="" type="post" id="login">
            <input type="hidden" value="{$url_shop_id}" id="url_shop_id">
            <div class="a-1">
                <img src="{:C('__STATIC__')}{$theme}/Static/img/login.png">
            </div>
            <div class="a-2">
                <input type="number" placeholder="请输入手机号" id="phone" maxlength="11"/>
                <input type="password" placeholder="请输入密码" id="password"/>
                <p class="ap"><a href="{:U('User/register', array('shop_id'=>session('url_shop_id')))}">快速注册</a><a href=""><!-- 忘记密码 --></a></p>
            </div>
            <button type="button" class="btn" id="save">登录</button>
            <!--<input type="submit" value="登录" class="btn" id="save"/>-->
        </form>
    </div>
    <script type="text/javascript" src="__PUBLIC__/jquery-1.10.2.js"></script>
    <script type="text/javascript" src="__PUBLIC__/usr/js/layer/layer.js"></script>
    <script type="text/javascript">
        function resize() {
            var clientWidth = document.documentElement.clientWidth;
            document.documentElement.style.fontSize = 100 * (clientWidth / 750) + 'px';
        }
        resize();
        window.addEventListener('resize', resize);
        $(function() {
            $('#save').click(function () {
                var phl = /^0?1[3|4|5|8|7|9][0-9]\d{8}$/;
                var phone = $("#phone").val();
                var password = $("#password").val();

                if(!phone || !phl.test(phone)){
                    layer.msg("手机号填写有误",{time: 1500});
                    $("#mobile").focus();
                    return false;
                }
                if(!password){
                    layer.msg("请填写密码",{time: 1500});
                    $("#password").focus();
                    return false;
                }
                $.ajax({
                    type: 'post',
                    url: "{:U('Login/index')}",
                    data: {
                        phone: phone,
                        password: password,
                        url_shop_id: $('#url_shop_id').val()
                    },
                    beforeSend:function() {
                        layer.msg("登陆中");
                    },
                    success: function (msg) {
                        if(msg && msg.status == "success") {
                            window.location.href = "{:U('Setting/personal')}";
                        } else {
                            layer.msg(msg.msg, {time:1500});
                        }
                    }
                });
            });
        });
    </script>
</body>
</html>
